package com.yeepal.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.yeepal.dao.LogicDAO;
import com.opensymphony.xwork2.Action;

public abstract class BaseAction implements Action{
    public LogicDAO logicDAO(){
        ServletContext servletContext = ServletActionContext.getServletContext();
        WebApplicationContext webApplicationContext= WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        return (LogicDAO)webApplicationContext.getBean("logicDAO");    
    }
    public HttpServletRequest request(){
        return ServletActionContext.getRequest();
    }
    public HttpSession session(){
        return ServletActionContext.getRequest().getSession();
    }
    public ServletContext application(){
        return ServletActionContext.getServletContext();
    }
    public HttpServletResponse response(){
        return ServletActionContext.getResponse();
    }
}

